<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>星星评价</title>

    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        body {
            font: 13px/1.5 Arial;
        }

        #star {
            position: relative;
            width: 600px;
            margin: 10px auto;
        }

        #star ul,
        #star span {
            float: left;
            height: 19px;
            line-height: 19px;
        }

        #star strong {
            color: #f60;
            padding-left: 10px;
        }

        #star span {
            font: 12px/1.5 Arial;
        }

        #star ul {
            margin: 0 20px;
        }

        #star li {
            list-style: none;
            text-indent: -9999px;
            float: left;
            width: 24px;
            cursor: pointer;
            background: url(img/star.png) no-repeat;
        }

        #star .on {
            background-position: 0 -28px;
        }

        #star p {
            position: absolute;
            top: 20px;
            width: 159px;
            height: 65px;
            background: url(img/icon.gif) no-repeat;
            padding: 7px 10px 2px;
            display: none;
        }

        #star p em {
            color: #f60;
            display: block;
            font-style: normal;
        }
    </style>

    <script>
        window.onload = function () {
            var Star = document.getElementById("star");
            var aLi = Star.getElementsByTagName('li');
            var oP = Star.getElementsByTagName('p')[0];
            var oSpan = Star.getElementsByTagName('span')[1];
            var aMsg = [
                "很不满意|差得太离谱，与卖家描述的严重不符，非常不满",
                "不满意|部分有破损，与卖家描述的不符，不满意",
                "一般|质量一般，没有卖家描述的那么好",
                "满意|质量不错，与卖家描述的基本一致，还是挺满意的",
                "非常满意|质量非常好，与卖家描述的完全一致，非常满意"
            ];
            var i = iScore = iStar = 0;

            for (i = 0; i < aLi.length; i++) {
                aLi[i].index = i + 1;
                aLi[i].onmouseover = function () {
                    oP.style.display = 'block';
                    fnPoint(this.index);
                    oP.style.left = this.offsetLeft + 12 - 92 + 'px';

                    oP.innerHTML = "<em><b>" + this.index + "</b> 分 " +
                        aMsg[this.index - 1].match(/(.+)\|/)[1] + "</em>" +
                        aMsg[this.index - 1].match(/\|(.+)/)[1];
                }

                aLi[i].onmouseout = function () {
                    fnPoint();
                    oP.style.display = 'none';
                }
                aLi[i].onclick = function () {
                    iStar = this.index;
                    oSpan.innerHTML = "<strong>" + (this.index) + " 分</strong> (" +
                        aMsg[this.index - 1].match(/\|(.+)/)[1] + ")";
                }
            }

            function fnPoint(iArg) {
                iScore = iArg || iStar;
                for (i = 0; i < aLi.length; i++) {
                    aLi[i].className = i < iScore ? 'on' : '';
                }
            }
        }
    </script>
</head>

<body>
    <div id="star">
        <span>点星星就能打分</span>
        <ul>
            <li>
                <a href="javascript:;">1</a>
            </li>
            <li>
                <a href="javascript:;">2</a>
            </li>
            <li>
                <a href="javascript:;">3</a>
            </li>
            <li>
                <a href="javascript:;">4</a>
            </li>
            <li>
                <a href="javascript:;">5</a>
            </li>
        </ul>
        <span>dfjakd</span>
        <p>
            <em>
                <b>3</b>分 一般
            </em>
            质量一般，没有卖家描述的那么好
        </p>
    </div>

</body>

</html>